from selenium import webdriver
from cfg import Const


#获取浏览器驱动
def getDriver(brType):
    driver = None
    if brType == Const.WBT_CHROME:
        try:
            driver = webdriver.Chrome()
        except Exception as e:
            driver = webdriver.Chrome(Const.PATH_CHROME_DRIVER)
    elif brType == Const.WBT_FIREFOX:
        driver = webdriver.Firefox()
    else:
        try:
            driver = webdriver.Ie()
        except Exception as e:
            driver = webdriver.Ie(Const.PATH_IE_DRIVER)
    return driver

def OpenWb(url, wbType=Const.WBT_FIREFOX):
    driver = getDriver(wbType)
    driver.get(url)
    return driver
